package com.primus.server.service.user.impl;

import com.primus.server.entity.user.User;
import com.primus.server.repository.UserRepository;
import com.primus.server.service.BaseServiceImpl;
import com.primus.server.service.user.UserService;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService {

    private final UserRepository userRepository;

    public UserServiceImpl(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    protected JpaRepository<User, Long> getRepository() {
        return this.userRepository;
    }

    @Override
    public User findByAccount(String account) {
        Optional<User> optional = this.userRepository.findByAccount(account);
        return optional.orElse(null);
    }
}
